/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.herenit.beijing.dh2011.security.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Obama
 */
@Entity
@Table(name = "SECURITY_MENU")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "SecurityMenu.findAll", query = "SELECT s FROM SecurityMenu s"),
    @NamedQuery(name = "SecurityMenu.findByMenuId", query = "SELECT s FROM SecurityMenu s WHERE s.menuId = :menuId"),
    @NamedQuery(name = "SecurityMenu.findByMenuName", query = "SELECT s FROM SecurityMenu s WHERE s.menuName = :menuName"),
    @NamedQuery(name = "SecurityMenu.findByCreateTime", query = "SELECT s FROM SecurityMenu s WHERE s.createTime = :createTime"),
    @NamedQuery(name = "SecurityMenu.findByUpdateTime", query = "SELECT s FROM SecurityMenu s WHERE s.updateTime = :updateTime"),
    @NamedQuery(name = "SecurityMenu.findByCreaterName", query = "SELECT s FROM SecurityMenu s WHERE s.createrName = :createrName"),
    @NamedQuery(name = "SecurityMenu.findByUpdaterTime", query = "SELECT s FROM SecurityMenu s WHERE s.updaterTime = :updaterTime")})
public class SecurityMenu implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 32)
    @Column(name = "MENU_ID")
    private String menuId;
    @Size(max = 32)
    @Column(name = "MENU_NAME")
    private String menuName;
    @Column(name = "CREATE_TIME")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
    @Column(name = "UPDATE_TIME")
    @Temporal(TemporalType.TIMESTAMP)
    private Date updateTime;
    @Size(max = 32)
    @Column(name = "CREATER_NAME")
    private String createrName;
    @Size(max = 32)
    @Column(name = "UPDATER_TIME")
    private String updaterTime;
    @OneToMany(mappedBy = "menuId")
    private List<SecurityMenuRole> securityMenuRoleList = new ArrayList<SecurityMenuRole>();
    @OneToMany(mappedBy = "menuId")
    private List<SecurityMenuPermission> securityMenuPermissionList = new ArrayList<SecurityMenuPermission>();
    @OneToMany(mappedBy = "fatherId")
    private List<SecurityMenu> securityMenuList = new ArrayList<SecurityMenu>();
    @JoinColumn(name = "FATHER_ID", referencedColumnName = "MENU_ID")
    @ManyToOne
    private SecurityMenu fatherId;
    @Size(max = 256)
    @Column(name = "MENU_PATH")
    private String menuPath;
    @Size(max = 32)
    @Column(name = "DISPLAY_NAME")
    private String displayName;
    @Size(max = 256)
    @Column(name = "ORIGINAL_FILE")
    private String originalFile;
    @Size(max = 256)
    @Column(name = "ICON")
    private String icon;
    @Column(name = "POSITION")
    private int position;
    @Size(max = 32)
    @Column(name = "LEAF")
    private boolean leaf;

    public SecurityMenu() {
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public boolean isLeaf() {
        return leaf;
    }

    public void setLeaf(boolean leaf) {
        this.leaf = leaf;
    }

    public SecurityMenu(String menuId) {
        this.menuId = menuId;
    }

    public String getMenuId() {
        return menuId;
    }

    public void setMenuId(String menuId) {
        this.menuId = menuId;
    }

    public String getMenuName() {
        return menuName;
    }

    public void setMenuName(String menuName) {
        this.menuName = menuName;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getCreaterName() {
        return createrName;
    }

    public void setCreaterName(String createrName) {
        this.createrName = createrName;
    }

    public String getUpdaterTime() {
        return updaterTime;
    }

    public void setUpdaterTime(String updaterTime) {
        this.updaterTime = updaterTime;
    }

    @XmlTransient
    public List<SecurityMenuRole> getSecurityMenuRoleList() {
        return securityMenuRoleList;
    }

    public void setSecurityMenuRoleList(List<SecurityMenuRole> securityMenuRoleList) {
        this.securityMenuRoleList = securityMenuRoleList;
    }

    @XmlTransient
    public List<SecurityMenuPermission> getSecurityMenuPermissionList() {
        return securityMenuPermissionList;
    }

    public void setSecurityMenuPermissionList(List<SecurityMenuPermission> securityMenuPermissionList) {
        this.securityMenuPermissionList = securityMenuPermissionList;
    }

    @XmlTransient
    public List<SecurityMenu> getSecurityMenuList() {
        return securityMenuList;
    }

    public void setSecurityMenuList(List<SecurityMenu> securityMenuList) {
        this.securityMenuList = securityMenuList;
    }

    public SecurityMenu getFatherId() {
        return fatherId;
    }

    public void setFatherId(SecurityMenu fatherId) {
        this.fatherId = fatherId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (menuId != null ? menuId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SecurityMenu)) {
            return false;
        }
        SecurityMenu other = (SecurityMenu) object;
        if ((this.menuId == null && other.menuId != null) || (this.menuId != null && !this.menuId.equals(other.menuId))) {
            return false;
        }
        return true;
    }

    public String getDisplayName() {
        return displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    public String getMenuPath() {
        return menuPath;
    }

    public void setMenuPath(String menuPath) {
        this.menuPath = menuPath;
    }

    public String getOriginalFile() {
        return originalFile;
    }

    public void setOriginalFile(String originalFile) {
        this.originalFile = originalFile;
    }

    public int getPosition() {
        return position;
    }

    public void setPosition(int position) {
        this.position = position;
    }

    @Override
    public String toString() {
        return "com.herenit.beijing.dh2011.security.SecurityMenu[ menuId=" + menuId + " ]";
    }
}
